import { calculatePower, findPower, findAllConfig } from '@/apis/calculatePowerAPI'
import type { PowerModel } from '@/types/model'
import { Record } from '@icon-park/vue-next'
import { ref } from 'vue'

const power = ref<PowerModel>()

export default () => {
  const configs = ref<ConfigViewModel[]>([])
  async function calcPower(config: CalcConfigModel, zoneId: number) {
    await calculatePower({ ...config, zoneId })
  }

  async function find(id: number) {
    const { data } = await findPower(id)
    power.value = data
  }

  async function allConfig(args: Record<string, any>) {
    const { data } = await findAllConfig(args)
    configs.value = data
  }

  return { calcPower, find, allConfig, configs, power }
}
